<template>
    <div class="menus-body" @mouseleave ="out">
        <div class="menus">
            <div class="menu-item" v-for="(item, index) in AsideCity" :key="index" @mouseenter="getItem(item,index)" >
                {{item.type}}
            </div>
        </div>
        <div class="sub-menus" v-if="getIndex">
            <ul>
                <li v-for="(item, index) in getChildren" :key="index">
                    <i>{{index + 1}}</i>
                    <strong>{{item.city}}</strong>
                    <span>{{item.desc}}</span>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            AsideCity:"",
            getIndex:0,
            getChildren:null
        }
    },
    created(){
        this.$axios({
            url:'/posts/cities',
        }).then(res=>{
            console.log(res.data);
            this.AsideCity = res.data.data
            
        })
    },
    methods:{
        getItem(item,index){
 
            this.getChildren = item.children
            this.getIndex = index+1
            console.log(this.getChildren);
            console.log(this.getIndex);
        },
        out(){
            this.getIndex = 0
        }
    }
}
</script>
<style lang="less" scoped>
.menus-body{
    position: relative;
    width: 610px;
    z-index: 2;
}
.menus{
    
    margin-top: 5px;
    width: 260px;
    border: 1px solid #dddddd;
    z-index: 2;
    border-right: none;
    border-bottom: none;
    position: relative;
    
    .menu-item{
        height: 40px;
        line-height: 40px;
        border-right: 1px solid #dddddd;
        border-bottom: 1px solid #dddddd;
        padding: 0 20px;
        font-size: 14px;
        box-sizing: border-box;
        // z-index: 3;
        background: #fff;
        &:hover{
            color: orange;
            border-right: orange;
        }

    }
}
.sub-menus{
    position: absolute;
    left: 260px;
    top: 0;
    width: 350px;
    padding: 10px 20px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #dddddd;
    box-sizing: border-box;
    

    ul{
        li{
            font-size: 14px;
            line-height: 1.5;

            i{
                color: orange;
                font-size: 24px;
                font-style: italic;
                
            }
            strong{
                font-weight: 400;
                color: orange;
                margin: 0 10px;
            }
            span{
                color: #666;
            }
        }
    }
}

</style>